package com.kn.order.controller;

import com.kn.common.model.PageBean;
import com.kn.common.model.R;
import com.kn.common.valid.AddGroup;
import com.kn.common.valid.EditGroup;
import com.kn.order.model.Contract;
import com.kn.order.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("order/order")
@RequiredArgsConstructor
@CrossOrigin
public class OrderController {
private final OrderService orderService;
@GetMapping
@RequiresPermissions("order:order:list")
    public R list(PageBean pageBean, String cdate,String container,String flowerNo,Boolean isfinish){
        return orderService.list(pageBean,cdate,container,flowerNo,isfinish);
}
@GetMapping("port")
public R port(){
    return orderService.port();
}
@GetMapping("customer")
    public R customer(){
        return orderService.customer();
    }
    @PutMapping("{id}")
    public R edit(@PathVariable Long id,@Validated(EditGroup.class)@RequestBody Contract contract){
        return orderService.edit(id,contract);
    }
    @GetMapping("/orderById/{id}")
    public R orderById(@PathVariable Long id){
        return orderService.orderById(id);
    }
    @GetMapping("packaging")
    public R packaging(){
        return orderService.packaging();
    }
    @GetMapping("product")
    public R product(){
        return orderService.product();
    }
    @GetMapping("technology")
    public R technology(){
        return orderService.technology();
    }
    @GetMapping("productWidth")
    public R productWidth(){
        return orderService.productWidth();
    }
    @GetMapping("simple")
    public R simple(){
        return orderService.simple();
    }
    @GetMapping("openScissors")
    public R openScissors(){
        return orderService.openScissors();
    }
    @DeleteMapping("{id}")
    public R delete(@PathVariable Long id){
        return orderService.delete(id);
    }
@PostMapping
    public R add(@Validated(AddGroup.class) @RequestBody Contract contract){
    return orderService.add(contract);
}
   /* @ApiOperation(value = "数据下载", notes = "数据下载")
    @PostMapping("getExcel")
    public R exportAddresses(HttpServletResponse response){
return orderService.exportAddresses(response);
    }
*/
    @GetMapping("export")
    public R export(){
        return orderService.export();
    }
}
